import 'package:flutter/material.dart';

/// 企业级响应式断点配置
/// 基于Material Design 3规范定义设备断点
class AppBreakpoints {
  /// 手机断点 - 最大宽度600dp
  static const double mobile = 600;
  
  /// 平板断点 - 最大宽度840dp
  static const double tablet = 840;
  
  /// 桌面断点 - 最大宽度1200dp
  static const double desktop = 1200;
  
  /// 大屏桌面断点 - 1200dp以上
  static const double largeDesktop = 1200;

  /// 检测是否为手机设备
  static bool isMobile(BuildContext context) {
    return MediaQuery.of(context).size.width < mobile;
  }

  /// 检测是否为平板设备
  static bool isTablet(BuildContext context) {
    final width = MediaQuery.of(context).size.width;
    return width >= mobile && width < tablet;
  }

  /// 检测是否为桌面设备
  static bool isDesktop(BuildContext context) {
    final width = MediaQuery.of(context).size.width;
    return width >= tablet && width < largeDesktop;
  }

  /// 检测是否为大屏桌面设备
  static bool isLargeDesktop(BuildContext context) {
    return MediaQuery.of(context).size.width >= largeDesktop;
  }

  /// 获取当前设备类型
  static DeviceType getDeviceType(BuildContext context) {
    final width = MediaQuery.of(context).size.width;
    
    if (width < mobile) return DeviceType.mobile;
    if (width < tablet) return DeviceType.tablet;
    if (width < largeDesktop) return DeviceType.desktop;
    return DeviceType.largeDesktop;
  }

  /// 获取响应式间距值
  static double getResponsiveValue({
    required BuildContext context,
    required double mobile,
    double? tablet,
    double? desktop,
    double? largeDesktop,
  }) {
    if (isLargeDesktop(context)) {
      return largeDesktop ?? desktop ?? tablet ?? mobile;
    }
    if (isDesktop(context)) {
      return desktop ?? tablet ?? mobile;
    }
    if (isTablet(context)) {
      return tablet ?? mobile;
    }
    return mobile;
  }
}

/// 设备类型枚举
enum DeviceType {
  mobile,      // 手机
  tablet,      // 平板
  desktop,     // 桌面
  largeDesktop, // 大屏桌面
}